using System;
using System.Collections.Generic;

namespace QueryBuilder.Core.Query.Presenters
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class PresentationMappings<T>
    {
        private IDictionary<string, Action<T>> mappings = new Dictionary<string, Action<T>>();

        /// <summary>
        /// Adds the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="presentationFactory">The presentation factory.</param>
        public void Add(string key, Action<T> presentationFactory)
        {
            this.mappings[key] = presentationFactory;
        }

        /// <summary>
        /// Gets the presentation factory.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public Action<T> GetPresentationFactory(string key)
        {
            if (this.mappings.ContainsKey(key))
            {
                return this.mappings[key];
            }
            return null;
        }
    }
}